package cn.gson.springmvc.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Objects;

@Entity
public class Inspect {
    private int patientId;
    private Integer inspectId;
    private String inspectTiem;
    private BigDecimal inspectMon;
    private Patient patientByPatientId;

    @Id
    @Column(name = "patient_id", nullable = false)
    public int getPatientId() {
        return patientId;
    }

    public void setPatientId(int patientId) {
        this.patientId = patientId;
    }

    @Basic
    @Column(name = "inspect_id", nullable = true)
    public Integer getInspectId() {
        return inspectId;
    }

    public void setInspectId(Integer inspectId) {
        this.inspectId = inspectId;
    }

    @Basic
    @Column(name = "inspect_tiem", nullable = true, length = 10)
    public String getInspectTiem() {
        return inspectTiem;
    }

    public void setInspectTiem(String inspectTiem) {
        this.inspectTiem = inspectTiem;
    }

    @Basic
    @Column(name = "inspect_mon", nullable = true, precision = 2)
    public BigDecimal getInspectMon() {
        return inspectMon;
    }

    public void setInspectMon(BigDecimal inspectMon) {
        this.inspectMon = inspectMon;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Inspect inspect = (Inspect) o;
        return patientId == inspect.patientId &&
                Objects.equals(inspectId, inspect.inspectId) &&
                Objects.equals(inspectTiem, inspect.inspectTiem) &&
                Objects.equals(inspectMon, inspect.inspectMon);
    }

    @Override
    public int hashCode() {
        return Objects.hash(patientId, inspectId, inspectTiem, inspectMon);
    }

    @OneToOne
    @JoinColumn(name = "patient_id", referencedColumnName = "patient_id", nullable = false)
    public Patient getPatientByPatientId() {
        return patientByPatientId;
    }

    public void setPatientByPatientId(Patient patientByPatientId) {
        this.patientByPatientId = patientByPatientId;
    }
}
